import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { NgxEchartsModule } from 'ngx-echarts';

import { AppComponent } from './app.component';
import { AppRouteMD } from './app-routing.module';
import { LoginModule } from './login/login.module';
import { JwtModule } from '@auth0/angular-jwt';
import { AuthGuard } from './core/service/auth/auth.guard.service';
import { ServiceModule } from './core/service/service.module';
import { NgValleyModule } from 'ng-valley';

import { UserInfoResolver } from './core/service/auth/auth.resolve.service';
import { InterceptorService } from './core/service/interceptor/interceptor.service';

export function tokenGetter() {
	return localStorage.getItem('token');
}

@NgModule({
	declarations: [
		AppComponent,
	],
	imports: [
		BrowserModule,
		BrowserAnimationsModule,
		FormsModule,
		HttpModule,
		HttpClientModule,
		NgxEchartsModule,
		AppRouteMD,
		LoginModule,
		ServiceModule,
		NgValleyModule,
		JwtModule.forRoot({
			config: {
				tokenGetter: tokenGetter,
				whitelistedDomains: [
					'localhost:4200', '192.168.188.102:9320', 'vpn.zywxg.com:9320', '191.168.1.107:9320', '156.156.156.127:9320', '192.168.188.136:9320'],
				blacklistedRoutes: [],
				throwNoTokenError: false
			}
		}),
	],
	providers: [
		{ provide: HTTP_INTERCEPTORS, useClass: InterceptorService, multi: true },
		AuthGuard,
		UserInfoResolver],
	bootstrap: [AppComponent]
})
export class AppModule { }
